<template>
    <u-popup :safeAreaInsetTop="true" mode="left" overlayOpacity="0.3" :show="MeShow" @close="MeShowclose"
             @open="openMePoP">
        <view class="MePoP">
            <!-- 个人信息 -->
            <view class="UserMsg">
                <view class="img_avatar">
                    <view class="img_top">
                        <image class="boder_r_50"
                               :src="nowstatus.infoData.userAvatar == null ? defaultAvatar : nowstatus.infoData.userAvatar"/>
                        <u-icon name="arrow-right" color="#000" style="position: relative; right: -50rpx" size="20"
                                @click="NavTo('/pages/Wode/msg')">
                        </u-icon>
                    </view>
                    <view class="img_down">
                        <view class="Name text_ovf">
                            {{ nowstatus.infoData.userNickName }}
                        </view>
                        <view class="RealName" @click="toRealName">
                            {{ realNameStatus == 1 ? "已实名" : "未实名" }}
                        </view>
                    </view>
                </view>
            </view>
            <!-- 满意度 | 订单 -->
            <view class="Satisfaction_Order flex_al_cen_ju_aro">
                <view class="Type" @click="NavTo('/pages/Wode/evaluation')">
                    <view> {{ nowstatus.infoData.userSatisfactionDegree }}%</view>
                    <view>满意度</view>
                </view>
                <!-- 分割线 -->
                <view class="partition"></view>
                <!--<view class="Type" @click="NavTo('/pages/Order/Order')">-->
                <view class="Type" @click="NavTo('/pages/Wode/orderStatistics')">
                    <view> {{ nowstatus.infoData.userCompletedOrderCount }}单</view>
                    <view>总订单</view>
                </view>
            </view>
            <!--操作列表 -->
            <view class="OperationList">
                <view class="Operation flex_al_cen_ju_bet" v-for="item in OperationList" :mode="item.mode"
                      :key="item.title" @click="item.click">
                    <view class="left flex">
                        <view class="icon">
                            <image :src="item.icon" :style="item.style"/>
                        </view>
                        <view>{{ item.title }}</view>
                    </view>
                    <view class="right">
                        <u-switch v-if="item.switch" v-model="Meswitch" size="20" @change="setStatus"
                                  activeColor="#FF0000">
                        </u-switch>
                    </view>
                </view>
            </view>
            <!-- 退出登录 -->
            <view class="exitLogin" @click="exitShow = true"> 退出登录</view>
        </view>
        <u-toast ref="uToast"></u-toast>
        <u-modal :show="exitShow" confirmText="退出" cancelText="取消" :showCancelButton="true" confirmColor="#0c22b0"
                 @cancel="exitShow = false" @confirm="exitLogin" title="退出提示"
                 content="您确定要退出当前这个账户吗？">
        </u-modal>
    </u-popup>
</template>
<script setup lang="ts">
import {onLoad, onShow} from "@dcloudio/uni-app";
import {defineProps, getCurrentInstance, defineEmits} from "vue";
import {NavTo} from "@/utlis/uni_api";
import {useStore} from "@/Pinia/index";
import MePoP from "@/Hooks/Home/MePoP"; // 导入Hooks
const defaultAvatar = "../../static/images/pulice/defaultAvatar.png";

interface Props {
    MeShow: Boolean;
}

interface emitTs {
    (event: "MeShowclose"): void;

    (event: "swtichChange"): void;
}

const {proxy} = getCurrentInstance() as any;
const Props = defineProps<Props>();
const emit = defineEmits<emitTs>();
const MeShowclose = () => {
    emit("MeShowclose");
};

const {
    openMePoP,
    Meswitch,
    OperationList,
    setStatus,
    exitLogin,
    realNameStatus,
    exitShow,
    toRealName
} = MePoP(proxy, emit);
const nowstatus = useStore();
onLoad(() => {
    // nowstatus.setStatus(proxy);
});
</script>
<style lang="scss" scoped>
@import "../../static/css/Home/MePoP.scss";
</style>
